package com.medical.admin.hospital.controller;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.medical.admin.hospital.common.dto.ComboTypeDto;
import com.medical.admin.hospital.common.vo.ComboTypeVo;
import com.medical.admin.hospital.common.vo.PageVo;
import com.medical.admin.hospital.service.ComboTypeService;
import com.qf.medical.response.ResponseEntity;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.constraints.NotNull;
/**
 * @description: 套餐类型信息管理
 * @author: LuAn
 * @date: 2024/4/27
 */
@Api(tags = "套餐类型管理Api在线文档")
@RestController
@RequestMapping("/comboType")
public class ComboTypeController {
    @Resource
    private ComboTypeService comboTypeService;

    @GetMapping("/page")
    @ApiOperation("查询套餐分类信息")
    @ApiImplicitParams({@ApiImplicitParam(name = "comboTypeTitle", value = "套餐分类标题"),
            @ApiImplicitParam(name = "pageNum",value = "当前页"),
            @ApiImplicitParam(name = "pageSize",value = "页大小")})
    public ResponseEntity<PageVo<ComboTypeVo>> list(String comboTypeName, @RequestParam(defaultValue = "1")
    int pageNum, @RequestParam(defaultValue = "10") int pageSize){
        return ResponseEntity.success(comboTypeService.list(comboTypeName,pageNum,pageSize));
    }

    @ApiOperation("新增套餐分类信息")
    @PostMapping("/add")
    @ApiImplicitParam(name = "comboTypeDto" ,value = "套餐分类信息")
    public ResponseEntity<Integer> add(@RequestBody ComboTypeDto comboTypeDto) throws JsonProcessingException {
        return ResponseEntity.success(comboTypeService.insert(comboTypeDto));
    }

    @ApiOperation("修改套餐分类信息")
    @PutMapping("/modify")
    @ApiImplicitParam(name = "comboTypeDto" ,value = "套餐分类信息")
    public ResponseEntity<Integer> modify(@RequestBody ComboTypeDto comboTypeDto){
        return ResponseEntity.success(comboTypeService.update(comboTypeDto));
    }

    @ApiOperation("删除套餐分类信息")
    @DeleteMapping("/remove")
    @ApiImplicitParam(name = "comboTypeId" ,value = "套餐分类ID")
    public ResponseEntity<Integer> remove(@NotNull Long comboTypeId){
        return ResponseEntity.success(comboTypeService.delete(comboTypeId));
    }

    @ApiOperation("查询套餐分类详情")
    @GetMapping("/detail")
    @ApiImplicitParam(name = "healthyEssayId" ,value = "套餐分类ID")
    public ResponseEntity<ComboTypeVo> detail(@NotNull Long comboTypeId){
        return ResponseEntity.success(comboTypeService.select(comboTypeId));
    }
}
